<template>
  <div class="recommend">
    <form action="/">
      <van-search
        v-model="value"
        show-action
        placeholder="请输入搜索关键词"
        @search="onSearch"
        @cancel="onCancel"
      />
    </form>
    <div class="guess">
      <div class="g_left">
        <span class="lovely">&nbsp;&nbsp;&nbsp;猜你喜欢</span>&nbsp;
        <span>
          <strong @click="change">换一批</strong>&nbsp;
          <i class="iconfont icon-shuaxin"></i>
        </span>
      </div>
      <div class="right">
        <span>兴趣定制</span>
      </div>
    </div>
    <div class="content">
      <ul>
        <li v-for="(item, index) in list" :key="index">
          <img :src="item.picUrl" alt="" />
          <p>
            <span>{{ item.category }}</span
            >&nbsp;
            <span>{{ item.copywriter }}</span>
          </p>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import { reqRadioApi } from "../../../api/redio";
import { Toast } from "vant";
export default {
  data() {
    return {
      value: "",
      list: [],
    };
  },
  computed: {},
  watch: {},

  methods: {
    onSearch(val) {
      Toast(val);
    },
    onCancel() {
      Toast("取消");
    },
    async love(num) {
      const params = { limit: 30, offset: num };
      const result = await reqRadioApi(params);
      console.log(result);
      if (result.status === 200) {
        this.list = result.data.djRadios;
        console.log(this.list);
      }
    },
    change() {
      const num = parseInt(Math.random() * 29);
      this.love(num);
    },

    //点击跳转到歌单页面
    /*   godinit(id) {
      this.$router.push({ name: "detail", params: { id } });
    }, */
  },
  created() {
    const num = parseInt(Math.random() * 29);
    this.love(num);
  },
  mounted() {},
  components: {},
};
</script>
<style scoped>
.van-search__content {
  border-radius: 20px;
  /* text-align: center; */
}
.content {
  width: 100%;
  /* clear: both; */
}
.content ul {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  padding-bottom: 55px;
}
.content ul li {
  display: inline-block;
  width: 30%;
}
.content ul li p span:nth-child(1) {
  font-size: 12px;
  /* text-align: center; */
  /* padding: 0.3em 0; */
  color: #aaa;
}
.content ul li p span:nth-child(2) {
  font-size: 14px;
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  display: block;
}
.content ul li img {
  width: 100%;
  border-radius: 20px;
}
.gyLike {
  font-weight: bold;
}
.guess {
  height: 2em;
  display: flex;
  position: relative;
  line-height: 2em;
}
.guess .left {
  position: absolute;
  top: 0;
  left: 20px;
  line-height: 2em;
}
.guess .left span {
  padding: 0 0.3em;
}
.guess .right {
  position: absolute;
  top: 0;
  right: 20px;
  height: 2em;
  font-size: 14px;
}
.guess .right span {
  background-color: #ccc;
  border-radius: 0.5em;
  height: 1.8em;
  /* line-height: 2em; */
}
</style>
